# -*- encoding:utf-8 -*-
"""
@作者：ven
@文件名：device.py
@时间：2021-08-25  15:24
@文档说明:
"""
import json

from common.GetConfig import config_ip
from common.Request import Request


class Device():

    def device_add(self, data, test_api_login):
        '''
        :param data: 增加部门传入的参数
        :param test_api_login: 鉴权Token
        :return:
        '''

        return Request().post(url=config_ip() + '/devices', data=json.dumps(data),
                              headers={'token': '{0}'.format(test_api_login),
                                       'Content-Type': 'application/json; charset=UTF-8',
                                       'X-Requested-With': 'XMLHttpRequest'})

    def device_del(self, data, test_api_login):
        '''
        :param  删除部门传入的部门ID
        :param test_api_login:
        :return:
        '''

        # return Request().delete(url=config_ip() + '/devices/',params=data,
        #                         headers={'token': '{0}'.format(test_api_login),
        #                                  'Content-Type': 'application/json; charset=UTF-8',
        #                                  'X-Requested-With': 'XMLHttpRequest'})
        return Request().delete(url=config_ip() + '/devices/{}'.format(data),
                                headers={'token': '{0}'.format(test_api_login),
                                         'Content-Type': 'application/json; charset=UTF-8',
                                         'X-Requested-With': 'XMLHttpRequest'})

    def device_edit(self, data, test_api_login):
        '''
        :param 修改设备信息
        :param test_api_login:
        :return:
        '''

        return Request().put(url=config_ip() + '/devices', data=json.dumps(data),
                             headers={'token': '{0}'.format(test_api_login),
                                      'Content-Type': 'application/json; charset=UTF-8',
                                      'X-Requested-With': 'XMLHttpRequest'})
